package com.yiyi.credit.manage.abutment.common.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.yiyi.credit.manage.abutment.common.enums.ResponseCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "返回结果")
public class APIResponse<T> implements Serializable {

    private static final long serialVersionUID = 355207958304927788L;


    @ApiModelProperty(value = "处理结果编码，10000:success")
    private String code = "10000";
    @ApiModelProperty(value = "处理结果信息")
    private String msg = "success";
    @ApiModelProperty(value = "请求流水号")
    private String requestNo;
    private String createTime;
    private T data;
    /*private Long timestamp = System.currentTimeMillis();*/

    public APIResponse() {

    }

    public APIResponse(ResponseCode code) {
        this.code = code.getCode();
        this.msg = code.getMessage();
    }

    public APIResponse(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public APIResponse(String code, String msg, String requestNo) {
        this.code = code;
        this.msg = msg;
        this.requestNo = requestNo;
    }

    public APIResponse(String msg) {
        this.msg = msg;
    }

    public APIResponse(T data) {
        this.data = data;
    }

    public APIResponse(T data, ResponseCode code) {
        this.data = data;
        this.code = code.getCode();
        this.msg = code.getMessage();
    }

    public APIResponse(ResponseCode code, String requestNo) {
        this.code = code.getCode();
        this.msg = code.getMessage();
        this.requestNo = requestNo;
    }

    public APIResponse(T data, String code, String msg, String requestNo) {
        this.data = data;
        this.code = code;
        this.msg = msg;
        this.requestNo = requestNo;
    }

    public APIResponse(T data, String code, String msg, String requestNo,String createTime) {
        this.data = data;
        this.code = code;
        this.msg = msg;
        this.requestNo = requestNo;
        this.createTime = createTime;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public APIResponse setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    /*public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }*/

    public String getRequestNo() {
        return requestNo;
    }

    public void setRequestNo(String requestNo) {
        this.requestNo = requestNo;
    }
}
